package m2;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;
import util.RabbitUtil;

import java.util.Scanner;

public class Producer {
    public static void main(String[] args) throws Exception {
        Connection connection = RabbitUtil.getConnection();

        Channel channel = connection.createChannel();
        /*创建队列
        * 参数说明:
        *   2. 是否是持久队列
        *
        * */
        channel.queueDeclare("task-queue", true, false, false, null);

        /*发送消息*/
        while (true){
            System.out.println("输入消息:");
            String s = new Scanner(System.in).nextLine();
            channel.basicPublish("", "task-queue", MessageProperties.PERSISTENT_BASIC, s.getBytes());
        }
    }
}
